package com.yilin.tms.capital.commons.strategy.tools;

import com.yilin.commons.exception.BusinessException;
import com.yilin.tms.capital.commons.strategy.operation.BankOperation;
import com.yilin.tms.capital.service.IPabService;
import com.yilin.tms.core.entity.capital.TradeRecord;
import com.yilin.tms.core.entity.user.account.Account;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

// 平安银行支付
public class PabBankOperation implements BankOperation {//添加需要在BankOperationFactory.class添加判断
    private final IPabService pabService;

    public PabBankOperation(IPabService pabService) {
        this.pabService = pabService;
    }

    /**
     * 支付
     * */
    @Override
    public void execute(List<TradeRecord> tradeRecordList, Account account) {
        pabService.transferCost(tradeRecordList,account);
    }
    /**
     * 退款
     * */
    @Override
    public TradeRecord executeRefund(TradeRecord tradeRecord, Account account) {
        pabService.transferCost(Collections.singletonList(tradeRecord), account);
        return tradeRecord;
    }
    /**
     * 查询
     * */
    @Override
    public TradeRecord executeQuery(TradeRecord tradeRecordList, Account account) {
        throw  new BusinessException("平安银行该接口未配置策略模式");
    }
}